package com.restaurant.application.indexes.accumulategoodslist;

import com.nebutown.description.DataTypes;
import com.nebutown.description.IndexGen;
import com.nebutown.description.UnitDescription;
import com.nebutown.description.data.Contributor;
import com.nebutown.description.data.IndexUnit;
import com.nebutown.description.data.SQLColumn;
import com.nebutown.generation.BeanSpec;
import com.nebutown.generation.basictype.UID;
import com.restaurant.application.accumulategoods.support.GoodsData;
import com.restaurant.application.genshanguser.GenShangUser;
import com.restaurant.application.goodscategory.support.CategoryData;
import com.restaurant.application.indexes.accumulategoodslist.mysql.AccumulateGoodsListCriteria;
import com.restaurant.application.shop.support.ShopVo;

public class AccumulateShopDesc extends UnitDescription {

    public static void main(String[] args) {
        UnitDescription desc = UnitDescription.basicUnit(AccumulateShop.class, null);
        desc.nextBean("MiniAccumulateShopPage")
                .add("goods", BeanSpec.listOf(GoodsData.class.getName()))
                .add("lists", BeanSpec.listOf(ShopVo.class.getName()))
                .add("types", BeanSpec.listOf(CategoryData.class.getName()))
                .add("accumulatePoints", Integer.class);

        desc.nextBean("PcAccumulateShopPage")
                .add("goodsList", BeanSpec.listOf(GoodsData.class.getName()))
                .add("accumulatePoint", Integer.class)
                .add("doSearchPath", String.class)
                .add("addGoodsPath", String.class)
                .add("accumulatePoints", Integer.class)
                // 积分方式，积分方法
                .add("accumulateType", UID.class);

        desc
                .addUiFunction("upGoods", null)
                .addUiFunction("downGoods", null)
                .addUiFunction("editGoods", null)
                .addUiFunction("createOtherGoods", null)
                .addUiFunction("createCoupon", null)
                .addUiFunction("searchGoods", AccumulateGoodsListCriteria.class.getName())
                .addUiFunction("showHistory", null)
        ;

        desc.run("./");
        IndexGen.run(getDescription(), "src/main/java");
    }

    public static IndexUnit getDescription() {
        return new IndexUnit()
                .withName("AccumulateGoodsList")
                .withPackageName(AccumulateShopDesc.class.getPackage().getName() + ".mysql")
                .withSrcLocation("./")
                .addContributors(new Contributor()
                        .withName("goodsUID")
                        .withNullable(false)
                        .withUnique(true)
                        .withUnitType(GenShangUser.class.getName())
                        .addContribution(new SQLColumn()
                                .withName("goodsName")
                                .withType(DataTypes.STRING)
                                .withLabel("商品名")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("state")
                                .withType(DataTypes.STRING)
                                .withLabel("商品状态")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("goodsType")
                                .withType(DataTypes.STRING)
                                .withLabel("商品类别")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("accumulatePoints")
                                .withType(DataTypes.LONG)
                                .withLabel("所需积分")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("goodsNumber")
                                .withType(DataTypes.LONG)
                                .withLabel("商品数量")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("soldNumber")
                                .withType(DataTypes.LONG)
                                .withLabel("售出数量")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("goodsId")
                                .withType(DataTypes.STRING)
                                .withLabel("商品Id")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("createTime")
                                .withType(DataTypes.LONG)
                                .withLabel("创建时间")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("modifyTime")
                                .withType(DataTypes.LONG)
                                .withLabel("修改时间")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("goodsDescribe")
                                .withType(DataTypes.STRING)
                                .withLabel("商品描述")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("shopId")
                                .withType(DataTypes.STRING)
                                .withLabel("店铺Id")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("typeId")
                                .withType(DataTypes.STRING)
                                .withLabel("种类Id")
                                .withWidth(255))
                        .addContribution(new SQLColumn()
                                .withName("price")
                                .withType(DataTypes.DOUBLE)
                                .withLabel("商品价格")
                                .withWidth(255))
                );
    }
}
